package AIbyDavid;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
public class testGeneticCode {
	public GeneticCode c;
	@Before
	public void testSetup(){
		c=new GeneticCode();
	}
	@Test
	public void testGenerateCode(){
		assertTrue(c.code.length()==110);
	}
	@Test
	public void testGetCodePart(){
		assertTrue(c.getCodePart(0).length()==110);
		assertTrue(c.getCodePart(1).length()==99);
		assertTrue(c.getCodePart(10).length()==0);
	}
	@Test 
	public void testEvaluateCode(){
		c.code="00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";//110 zero
		c.evaluateCode();
		assertTrue(c.codeFitness==0);
		c.code="10000000001000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";//110 zero
		c.evaluateCode();
//		System.out.println(c.codeFitness);
		assertTrue(c.codeFitness==-2);
		c.code="10000000001000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";//110 zero
		c.evaluateCode();
//		System.out.println(c.codeFitness);
		assertTrue(c.codeFitness==-10);
		c.code="10000000001000000000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000010";//110 zero
		c.evaluateCode();
//		System.out.println(c.codeFitness);
		assertTrue(c.codeFitness==-14);
		
	}
	@Test
	public void testMutate(){
//		String s=c.code;
//		c.mutate();
//		System.out.println(s.compareTo(c.code));
//		c.mutate();
//		System.out.println(s.compareTo(c.code));
//		c.mutate();
//		System.out.println(s.compareTo(c.code));
	}
	@Test 
	public void testMerge(){
		//todo
	}
	
}
